<meta charset="utf-8" />
<div class="breadcrumbs" id="breadcrumbs">
	<ul class="breadcrumb">
		<li><i class="ace-icon fa fa-home home-icon"></i> <a href="index">主页</a>
		</li>
		<li><span>控制台</span></li>
	</ul>
	<!-- /.breadcrumb -->
</div>

<div class="page-content">
	<div class="row">
		<div class="col-xs-12">
			<!-- 66666 -->
			<div class="clearfix"></div>
			<div class="tabbable">
				<!-- Only required for left/right tabs -->
				<ul class="nav nav-tabs">
					<li class="active"><a href="#tab1" data-toggle="tab">未排产订单</a></li>
					<!-- <li><a href="#tab2" data-toggle="tab"
						onclick="javascript:ypckkk();">已排产订单</a></li>
					<li><a href="#tab3" data-toggle="tab"
						onclick="javascript:ypckkk1();">入库及闭单</a></li> -->
				</ul>
			</div>
			<br>
			<!-- <div class="table-header">生产订单信息</div> -->

			<div class="tab-content">
				<!-- 不同的内容 -->
				<div class="tab-pane active" id="tab1">
					<!-- 待排产 -->
					<div class="table-header">生产订单信息(销售订单信息)</div>
					<div id="dynamic-table_wrapper"
						class="dataTables_wrapper form-inline no-footer">
						<div class="row">
							<div class="col-xs-12">
								<form id="selefrom1" class="form-inline" action="scjhgl/sele1"
									method="post">
									生产订单号&nbsp;&nbsp;<input type="search"
										style="width:120px;height:30px "
										;class="form-control input-sm" aria-controls="dynamic-table"
										name="scddh" onfocus="clears()" id="abcd">

									客户简称&nbsp;&nbsp;<input type="search"
										style="width:120px;height:30px "
										;class="form-control input-sm" aria-controls="dynamic-table"
										name="khjc" onfocus="clears()" id="efgh">

									存货编码&nbsp;&nbsp;<input type="search"
										style="width:120px;height:30px "
										; class="form-control input-sm" aria-controls="dynamic-table"
										name="chbm" onfocus="clears()" id="hijk">

									<button id="selectfromsb1" class="btn btn-mini btn-primary">查询</button>


									<div class="pull-right col-xs-0">
								</form>
								<form id="sub" method="post" enctype="multipart/form-data">
									<div hidden="hidden" id="inputfile">
									  <input type="file" name="file" id="a" />
									</div>
									  <!-- <a id="pc1" href="" class="btn btn-mini btn-primary">自动排产</a> -->
									  <a href="javascript:addForm()" class="btn btn-mini btn-primary">需求录入</a>
									  <input id="filename" type="button" name="filename" onclick="mouseOver();" class="btn btn-mini btn-primary"	value="需求导入" /> 
									  <a id="pc11" href="" class="btn btn-mini btn-primary">删除</a>
									<!--  <a href="#" class="btn btn-mini btn-primary">打印</a>  -->
									<!-- <input type="button" id="" onclick="exportexcel();"class="btn btn-mini btn-primary" value="导出" /> -->
									<a href="date/exportexcel1" class="btn btn-mini btn-primary">导出</a>
								</form>
							</div>


						</div>
					</div>
				</div>

				<table
					class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable"
					role="grid">
					<thead>
						<tr role="row">
							<th class="center"><label> <input type="checkbox"
									class="ace" /> <span class="lbl"></span>
							</label></th>
							<th>发货日期</th>
							<th>销售订单号</th>
							<th>生产订单号</th>
							<th>客户简称</th>
							<th>存货编码</th>
							<th>存货名称</th>
							<th>规格型号</th>
							<th>单位</th>
							<th>订单数量</th>
							<th>备注</th>
							<!-- <th>计划排产数</th> -->
						</tr>
					</thead>
					<tbody id="table_1">
					</tbody>
				</table>





				<div class="breadcrumbs" id="breadcrumbs">
					<!-- 分页 -->
					<div class="col-xs-6">
						<div class="dataTables_length" id="dynamic-table_length">
							<label>显示 <select name="selectname"
								aria-controls="dynamic-table" class="selectclass">
									<option value="10">10</option>
									<option value="20">20</option>
									<option value="50">50</option>
									<option value="100">100</option>
							</select> 记录
							</label>
						</div>
					</div>
				

					<div class="text-right">
					
						<!-- 默认显示一行的div -->
										<div class="dataTables_paginate paging_simple_numbers"
											id="dynamic-table_paginate1">
											<ul class="pagination" id="get_pagination1">
												
											</ul>
											<div name="laypage1.3" class="laypage_main laypageskin_molv"
													id="laypage_1">
													<span class="laypage_curr" style="background-color:#2283C5">1</span><span
														class="laypage_total"><label>到第</label><input
														max="1" min="1" class="laypage_skip" type="number"><label>页</label>
														<button type="button" class="laypage_btn">确定</button></span>
											</div>
										</div>
					</div>
				</div>
			</div>
			<!--tab1结束  -->






			<div class="tab-pane" id="tab2">
				<div class="table-header">已排产订单信息</div>
				<div id="dynamic-table_wrapper"
					class="dataTables_wrapper form-inline no-footer">


					<div class="row">
						<form id="selefrom2" class="form-inline" action="scjhgl/sele2"
							method="post">
							&nbsp;&nbsp;&nbsp;&nbsp;生产订单号&nbsp;&nbsp;<input type="search"
								style="width:120px;height:30px " ; class="form-control input-sm"
								aria-controls="dynamic-table" name="scddh" onfocus="clears1()"
								id="ww1"> 客户简称&nbsp;&nbsp;<input type="search"
								style="width:120px;height:30px " ; class="form-control input-sm"
								aria-controls="dynamic-table" name="khjc" onfocus="clears2()"
								id="ww2"> 存货编码&nbsp;&nbsp;<input type="search"
								style="width:120px;height:30px " ; class="form-control input-sm"
								aria-controls="dynamic-table" name="chbm" onfocus="clears3()"
								id="ww3">

							<button id="selectfromsb2" class="btn btn-mini btn-primary">查询</button>

							<div class="pull-right col-xs-0">
								<a id="pc2" href="" class="btn btn-mini btn-primary">自动排产</a>
								<!-- 	<a href="#" class="btn btn-mini btn-primary">打印</a>  -->
								<!-- <input type="button" name="" id="" onclick="writeExcel2();"
									class="btn btn-mini btn-primary" value="导出" /> -->
									<a href="date/exportexcel2" class="btn btn-mini btn-primary">导出</a>
							</div>
						</form>
					</div>
				</div>





				<table
					class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable"
					role="grid" aria-describedby="dynamic-table_info">
					<thead>
						<tr role="row">
							<th class="center"><label> <input type="checkbox"
									class="ace" /> <span class="lbl"></span>
							</label></th>
							<th>生产订单号</th>
							<th>发货日期</th>
							<th>客户简称</th>
							<th>存货编码</th>
							<th>存货名称</th>
							<th>规格型号</th>
							<th>单位</th>
							<th>订单数量</th>
							<th>生产序号</th>
							<th>生产班组</th>
							<th>累计排产数</th>
							<th>累计完工数</th>
							<th>待排产数</th>
							<th>计划排产班组</th>
							<th>计划排产数</th>
							<!-- <th>操作</th> -->
						</tr>
					</thead>
					<tbody id="table_2"></tbody>
				</table>


				<div class="breadcrumbs" id="breadcrumbs">
					<!-- 分页 -->
					<div class="col-xs-6">
						<div class="dataTables_length" id="dynamic-table_length2">
							<label>显示 <select name="selectname1"
								aria-controls="dynamic-table" class="selectclass1">
									<option value="10">10</option>
									<option value="20">20</option>
									<option value="50">50</option>
									<option value="100">100</option>
							</select> 记录
							</label>
						</div>
					</div>


					<div class="text-right">
						<div class="dataTables_paginate paging_simple_numbers"
											id="dynamic-table_paginate1">
											<ul class="pagination" id="get_pagination2">
												
											</ul>
											<div name="laypage1.3" class="laypage_main laypageskin_molv"
													id="laypage_2">
													<span class="laypage_curr" style="background-color:#2283C5">1</span><span
														class="laypage_total"><label>到第</label><input
														max="1" min="1" class="laypage_skip" type="number"><label>页</label>
														<button type="button" class="laypage_btn">确定</button></span>
											</div>
										</div>
					</div>
				</div>

			</div>
			<!--tab2结束  -->



			<div class="tab-pane" id="tab3">
				<!-- 已闭单 -->
				<div class="table-header">入库及闭单信息</div>
				<div id="dynamic-table_wrapper"
					class="dataTables_wrapper form-inline no-footer">

					<div class="row">
						<form id="selefrom3" class="form-inline" action="scjhgl/sele3"
							method="post">
							&nbsp;&nbsp;&nbsp;&nbsp;生产订单号&nbsp;&nbsp;<input type="search"
								style="width:120px;height:30px " ; class="form-control input-sm"
								aria-controls="dynamic-table" name="scddh" onfocus="clears4()"
								id="abcd1"> 客户简称&nbsp;&nbsp;<input type="search"
								style="width:120px;height:30px " ; class="form-control input-sm"
								aria-controls="dynamic-table" name="khjc" onfocus="clears4()"
								id="abcd2"> 存货编码&nbsp;&nbsp;<input type="search"
								style="width:120px;height:30px " ; class="form-control input-sm"
								aria-controls="dynamic-table" name="chbm" onfocus="clears4()"
								id="abcd3">

							<button id="selectfromsb3" class="btn btn-mini btn-primary">查询</button>

							<div class="pull-right col-xs-0">
								<a href="javascript:BD()" class="btn btn-mini btn-primary">关闭计划</a>
								<!-- 	<a href="#" class="btn btn-mini btn-primary">打印</a> -->
								<!-- <input type="button" name="" id="" onclick="writeExcel();" class="btn btn-mini btn-primary" value="导出" /> -->
								<a href="date/exportexcel2" class="btn btn-mini btn-primary">导出</a>
							</div>
						</form>
					</div>

				</div>

				<table
					class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable"
					id="dynamic-table" role="grid"
					aria-describedby="dynamic-table_info">
					<thead>
						<tr role="row">
							<th class="center"><label> <input type="checkbox"
									class="ace" /> <span class="lbl"></span>
							</label></th>
							<th>生产订单号</th>
							<th>发货日期</th>
							<th>客户简称</th>
							<th>存货编码</th>
							<th>存货名称</th>
							<th>规格型号</th>
							<th>单位</th>
							<th>订单数量</th>
							<th>成品入库数</th>
						</tr>
					</thead>
					<tbody id="table_3">
					</tbody>
				</table>

				<div class="breadcrumbs" id="breadcrumbs">
					<!-- 分页 -->

					<div class="col-xs-6">
						<div class="dataTables_length" id="dynamic-table_length3">
							<label>显示 <select name="selectname2"
								aria-controls="dynamic-table" class="selectclass2">
									<option value="10">10</option>
									<option value="20">20</option>
									<option value="50">50</option>
									<option value="100">100</option>
							</select> 记录
							</label>
						</div>
					</div>

					<div class="text-right">
						<div class="dataTables_paginate paging_simple_numbers"
											id="dynamic-table_paginate1">
											<ul class="pagination" id="get_pagination3">
												
											</ul>
											<div name="laypage1.3" class="laypage_main laypageskin_molv"
													id="laypage_3">
													<span class="laypage_curr" style="background-color:#2283C5">1</span><span
														class="laypage_total"><label>到第</label><input
														max="1" min="1" class="laypage_skip" type="number"><label>页</label>
														<button type="button" class="laypage_btn">确定</button></span>
											</div>
										</div>
					</div>
				</div>

			</div>
			<!--tab3结束  -->



		</div>


	</div>
</div>





<!-- 新增生产订单 -->
<div class="hide" id="add">
	<form id="pform" action="scjhgl/c" method="post">
		<input type="hidden" name="id">
		<!-- 在div中隐藏 -->
		<div class="form-group">
			<label class="col-sm-3 control-label no-padding-right"
				for="scdd.xsddh">销售订单号：</label>
			<div class="col-sm-9">
				<td><input type="text" placeholder="请输入销售订单号"
					style="width:260px;height:27px " value="" id="scdd.xsddh"
					name="scdd.xsddh" class="caaa1" /><font color=#ff0000>(必填)</font>
				</td>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label no-padding-right"
				for="scdd.khjc">客户简称：</label>
			<div class="col-sm-9">
				<td><input type="text" placeholder="请输入客户简称"
					style="width:260px;height:27px " id="scdd.khjc" name="scdd.khjc"
					value="" class="caaa11" /><font color=#ff0000>(必填)</font></td>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label no-padding-right"
				for="scdd.chbm">存货编码：</label>
			<div class="col-sm-9">
				<td><input ty pe="text" placeholder="请输入存货编码"
					style="width:260px;height:27px " id="scdd.chbm" name="scdd.chbm"
					value="" class="caaa111" /><font color=#ff0000>(必填)</font></td>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label no-padding-right"
				for="scdd.chmc">存货名称：</label>
			<div class="col-sm-9">
				<td><input type="text" placeholder="请输入存货名称"
					style="width:260px;height:27px " id="scdd.chmc" name="scdd.chmc"
					value="" class="caaa1111" /><font color=#ff0000>(必填)</font></td>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label no-padding-right"
				for="scdd.ggxh">规格型号：</label>
			<div class="col-sm-9">
				<input type="text" placeholder="请输入规格型号"
					style="width:260px;height:27px " id="scdd.ggxh" name="scdd.ggxh"
					value="" class="caaa2" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label no-padding-right"
				for="scdd.fhrq">发货日期：</label>
			<div class="col-sm-9">
				<td><input type="text" placeholder="请输入发货日期"
					style="width:260px;height:27px " id="scdd.fhrq" name="scdd.fhrq"
					onClick="WdatePicker()" value="" class="caaa22" /><font
					color=#ff0000>(必填)</font></td>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label no-padding-right" for="scdd.dw"
				class="caaa222">单 &nbsp&nbsp&nbsp&nbsp&nbsp 位：</label>
			<div class="col-sm-9">
				<input type="text" placeholder="请输入单位"
					style="width:260px;height:27px " id="scdd.dw" name="scdd.dw"
					value="" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label no-padding-right"
				for="scdd.ddsl" class="caaa2" class="caaa2222">订单数量：</label>
			<div class="col-sm-9">
				<td><input type="text" placeholder="请输入订单数量"
					style="width:260px;height:27px " id="scdd.ddsl" class="caaa11112"
					name="scdd.ddsl" value="" /><font color=#ff0000>(必填)</font></td>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label no-padding-right" for="scdd.bz">备
				&nbsp&nbsp&nbsp&nbsp&nbsp 注：</label>
			<div class="col-sm-9">
				<input type="text" placeholder="请输入备注"
					style="width:260px;height:27px " id="scdd.bz" name="scdd.bz"
					value="" />
			</div>
		</div>
	</form>
</div>

</div>


<script type="text/javascript">
	function ypckkk() {
		showPage2(1);
	}

	function ypckkk1() {
		showPage3(1);
	}
</script>


<script type="text/javascript">
	//未排产订单

//鼠标经过变色
$("#tab2").delegate("tr","mouseover",function(){  
            $(this).addClass("tr-mouseover");  
            $(this).css("background-color","#307ecc");   
        });   
    $("#tab2").delegate("tr","mouseout",function(){  
        $(this).removeClass("tr-mouseover");  
        $(this).css("background-color","");  
    });

$("#tab3").delegate("tr","mouseover",function(){  
            $(this).addClass("tr-mouseover");  
            $(this).css("background-color","#307ecc");   
        });   
    $("#tab3").delegate("tr","mouseout",function(){  
        $(this).removeClass("tr-mouseover");  
        $(this).css("background-color","");  
    });
	//查询时输入框以外的输入框清空
	function clears() {
		document.getElementById("abcd").value = "";
		document.getElementById("efgh").value = "";
		document.getElementById("hijk").value = "";
	}
	$("#selectfromsb1").click(function() {
		$.post("scjhgl/sele1",$("#selefrom1").serialize(),function(data){
					showPage1(1);
		});
		return false;
	});
	
	 function aa() {//当刷新页面时重新执行查询方法
		$.post("scjhgl/sele1",$("#selefrom1").serialize(),function(data){
					showPage1(1);
		});
		}
     aa();//调用查询方法
	// 导入销售订单
	function mouseOver() {
		/* $.post("date/excleIn",function(data){
			alert("aaa");
			}); */
		$("#inputfile").removeClass("hidden");
		//使用layer的确认窗口进行上传文件，可以避免使用根据input的值变化触发上传带来的bug。
		var index = layer.open({
			type : 1,
			title : "订单导入",
			area : [ '400px', '230px' ],
			content : $("#inputfile"),
			btn : [ "导入", "取消" ],
			success:function(){
				//$("#a").click();
				$("#a").val("");
			},
			yes : function() {
				//判断input是否已经输入
				if ($("#a").val() == "") {
					layer.msg("请选择需要导入的文件");
					return false;
				}			
				//执行文件上传
				var formData = new FormData($("#sub")[0]);

				$.ajax({
					url : "date/excelIn",
					type : 'POST',
					data : formData,
					async : false,
					cache : false,
					contentType : false,
					processData : false,
					success : function(data) {
						showPage1(1);
						layer.alert(data);
					}
				});
				//关闭弹窗
				$("#inputfile").addClass("hidden");
				layer.close(index);

			},
			cencel : function() {
				layer.closeAll();
			}
		});

		//由input的值改变触发上传，会导致取消输入的内容时也会触发，有bug
		/* $("#a").change(function(data) {
		var formData = new FormData($("#sub")[0]);
		$.ajax({
			url : 'date/excleIn',
			type : 'POST',
			data : formData,
			async : false,
			cache : false,
			contentType : false,
			processData : false,
			success : function(returndata) {
			    showPage1(1);
			    atter = returndata;
			    //alert(returndata);
			    if(returndata=="aaaa11"){
			    layer.alert("该订单存货编码已经导入过了");
		           }else{					
				layer.alert("请在pdm中添加此存货编码"+returndata+"");
				}				
			}
		}); 
		});  */

	}
	// 导出 
	function exportexcel() {
		writeExcel();
		$.post("date/exportexcel", function(data) {
			alert("aaaa");

		});

	}

	function writeExcel() {

		var aa = '未排产';
		// alert(aa);
		$.post("date/writeExcel", {
			"aa" : aa
		}, function(data) {
			if (data == "ss") {

				alert("导出成功，在C盘根目录请注意查收！");
				window.location = "#scjhgl/index";
			} else {
				alert("导出失败");
				window.location = "#scjhgl/index";
			}

		});
	}

	//$(document).ready(function() { 

	function mouseOut() {
		$("#fileselect").attr('type', 'button');
		$("#fileselect").attr('value', '导入订单信息');
	}

	function WPC(data) { //未排产
		var dataStr = "";
		$
				.each(
						data,
						function(i, a) {
							$
									.each(
											a.paginate.list,
											function(i, v) { //v. _ rscjh表数据   a.paginate.list -->v

												dataStr += '<tr>';

												dataStr += '<td><input name="checkboxs1"  id="checkboxs1" class="ace" type="checkbox" value="'+v.id+'"/> <span class="lbl"></span></td>'; //<form name="pc1" action="scjhgl/PC1" method="post"></form>

												if (v.fhrq == null
														|| v.fhrq == 'null'
														|| v.fhrq == '') {
													dataStr += '<td  style="width:100px;height:30px " class="fhrq'+v.id+'">'
															+ '' + '   </td>';
												} else {
													dataStr += '<td  style="width:100px;height:30px " class="fhrq'+v.id+'">'
															+ v.fhrq
															+ '   </td>';
												}
												if (v.xsddh == null
														|| v.xsddh == 'null'
														|| v.xsddh == '') {
													dataStr += '<td>' + ''
															+ '</td>';//销售订单号

												} else {
													dataStr += '<td>' + v.xsddh
															+ '</td>';//销售订单号
												}
												if (v.scddh == null
														|| v.scddh == 'null'
														|| v.scddh == '') {
													dataStr += '<td  class=" scddh'+v.id+'"><input type="hidden" value="'+v.id+'" /><input name="scddh" type="text" useid="'+v.id+'" class="caaa form-control editButton dddd'+i+'" style="width:100px;height:30px " id="scddh'+v.id+'"  value="'+''+'"  /></td>';
												} else {
													dataStr += '<td  class=" scddh'+v.id+'"><input type="hidden" value="'+v.id+'" /><input name="scddh" type="text" useid="'+v.id+'" class="caaa form-control editButton dddd'+i+'" style="width:100px;height:30px " id="scddh'+v.id+'"  value="'+v.scddh+'"  /></td>';
												}

												if (v.khjc == null
														|| v.khjc == 'null'
														|| v.khjc == '') {
													dataStr += '<td style="width:80px;height:30px ">'
															+ '' + '</td>';//客户简称
												} else {
													dataStr += '<td style="width:80px;height:30px ">'
															+ v.khjc.substring(
																	0, 4)
															+ '</td>';//客户简称
												}

												if (v.chbm == null
														|| v.chbm == 'null'
														|| v.chbm == '') {
													dataStr += '<td>' + ''
															+ '</td>';//存货编码
												} else {
													dataStr += '<td>' + v.chbm
															+ '</td>';//存货编码
												}

												if (v.chmc == null
														|| v.chmc == 'null'
														|| v.chmc == '') {
													dataStr += '<td>' + ''
															+ '</td>';//存货名称
												} else {
													dataStr += '<td>' + v.chmc
															+ '</td>';//存货名称
												}

												if (v.ggxh == null
														|| v.ggxh == 'null'
														|| v.ggxh == '') {
													dataStr += '<td style="width:160px;height:27px " >'
															+ '' + '</td>';//规格型号
												} else {
													dataStr += '<td style="width:160px;height:27px " >'
															+ v.ggxh + '</td>';//规格型号
												}

												if (v.dw == null
														|| v.dw == 'null'
														|| v.dw == '') {
													dataStr += '<td>' + ''
															+ '</td>';//单位
												} else {
													dataStr += '<td>' + v.dw
															+ '</td>';//单位

												}

												if (v.ddsl == null
														|| v.ddsl == 'null'
														|| v.ddsl == '') {
													dataStr += '<td>' + ''
															+ '</td>';
												} else {
													dataStr += '<td>' + v.ddsl
															+ '</td>';
												}

												if (v.bz == null
														|| v.bz == 'null'
														|| v.bz == '') {
													dataStr += '<td>' + ''
															+ '</td>';//备注   
												} else {
													dataStr += '<td>' + v.bz
															+ '</td>';//备注
												}
												/* dataStr += '<td  class="jhpcs'+v.id+'" ><input type="hidden" value="'+v.id+'" /><input name="jhpcsaaa" type="text" useid="'+v.id+'" class="caaabb form-control editButton dddd'+i+'" style="width:60px;height:30px "  id="qazaa"  value="'+v.ddsl+'"  /></td>'; */
/* 												dataStr += '<td  class=" jhpcs'+v.id+'"><input type="hidden" id="hqid" value="'+v.id+'" /><input name="jhpcs" type="text" useid="'+v.id+'" class="caaabb112 form-control editButton dddd'+i+'" style="width:60px;height:30px " id="jhpcs'+v.id+'"  value="'+v.ddsl+'"  /></td>';
 */												
                                                dataStr += '</tr>';
												dataStr += '</tr>';

											});
						});
		//return dataStr;
		$("#table_1").html(dataStr);

		$(".caaa").blur(function() {
			clickEdit1($(this));
			//window.location = "#scjhgl/index" ;
			return false;

		});
		///////
		$(".caaabb112").blur(function() {
			clickEdita($(this));
			//window.location = "#scjhgl/index" ;
			return false;

		});

		$(".caaa1").blur(function() {

			var a = document.getElementById("scdd.xsddh").value;
			var c = a.length;
			if (c != 11) {
				document.getElementById("scdd.xsddh").value = "";
				//document.getElementById("scdd.xsddh").reset();
				layer.alert("请输入11位正确格式如1：20160828001");

			}
			/*  else if(!isNaN(a)){
			 alert("请输入11位正确格式如2：20160828001");
			 } */

			return false;
		});

		$(".caaa11").blur(function() {
			var a = document.getElementById("scdd.khjc").value;
			var c = a.length;

			if (!isNaN(a) && c < 15) {

				layer.alert("请输入汉字！");
				document.getElementById("scdd.khjc").value = "";
			}

			return false;
		});

		$(".caaa111").blur(function() {

			var a = document.getElementById("scdd.chbm").value;
			var c = a.length;
			// alert(a.length);
			if (c != 11) {
				layer.alert("请输入11位正确格式如1：20403140302");
			}

			clickEdit11($(this));
			/* $.post("scjhgl/chbmjy",{"a":a},function(data){
			 if (data == "ss"){
			
			   	alert("导出成功，在C盘根目录请注意查收！");
			
			}
			 */

			return false;
		});

		$(".caaa1111").blur(function() {
			var a = document.getElementById("scdd.chmc").value;
			var c = a.length;

			if (!isNaN(a) && c < 15) {
				layer.alert("请输入汉字！");
				document.getElementById("scdd.chbm").value = "";
			}
			return false;
		});

		$(".caaa11112").blur(function() {
			var a = document.getElementById("scdd.ddsl").value;
			var c = a.length;

			if (isNaN(a)) {
				layer.alert("请输入数字！");
				document.getElementById("scdd.ddsl").value = "";
			}
			return false;
		});

		var now = new Date(); //获取当前时间----------------
		var year = now.getFullYear(); //年
		var month = now.getMonth() + 1; //月
		var day = now.getDate(); //日
		var clock = year + "-";
		if (month < 10)
			clock += "0";
		clock += month + "-";
		if (day < 10)
			clock += "0";
		clock += day + " ";

		$
				.each(
						data,
						function(i, a) {
							$
									.each(
											a.paginate.list,
											function(i, v) {

												var fhrq = $(
														"#table_1 .fhrq" + v.id)
														.text();
												var OneMonth = fhrq.substring(
														5,
														fhrq.lastIndexOf('-')); //时间相减-------------
												var OneDay = fhrq
														.substring(
																fhrq.length,
																fhrq
																		.lastIndexOf('-') + 1);
												var OneYear = fhrq.substring(0,
														fhrq.indexOf('-'));

												var TwoMonth = clock.substring(
														5,
														clock.lastIndexOf('-'));
												var TwoDay = clock
														.substring(
																clock.length,
																clock
																		.lastIndexOf('-') + 1);
												var TwoYear = clock.substring(
														0, clock.indexOf('-'));

												var cha = ((Date.parse(OneMonth
														+ '/' + OneDay + '/'
														+ OneYear) - Date
														.parse(TwoMonth + '/'
																+ TwoDay + '/'
																+ TwoYear)) / 86400000); //时间相减-------------
											

												/* if (cha <= '3') {
													$("#table_1 .fhrq" + v.id)
															.parent()
															.css(
																	"background-color",
																	"#ff66cc");
												} else if ('3' < cha
														&& cha < '8') {
													$("#table_1 .fhrq" + v.id)
															.parent()
															.css(
																	"background-color",
																	"#ffff66");
												} */

											});
						});

	}//页面输出结束标志

	//获取分页数据列表并显示
	function showPage1(curr) {
		$.get("scjhgl/Tbody_list1", {
			"pageNumber" : curr,
			"size" : $(".selectclass").val()
		}, function(data) {
			WPC(data);
			PageFoot1(data[0].paginate); //调用的PageFoot方法，循环输出页码连接    

		});

	}

	//showPage1(1); //刚进入页面为第一页，列出第一页数据和页脚			

	function clickEdit1(obj) {
		var id = obj.attr("useid");
		var scddh = $("#scddh" + id).val();
		if (!isNaN(scddh)) {

			$.post("scjhgl/luru", {
				"scddh" : scddh,
				"id" : id
			}, function(data) {//data表示接收后台传递的参数,"wwgs":z,
				showPage1(1);
			});

		} else {
			layer.msg("请输入正确的数据格式！！！");
		}
	}

	function clickEdit11(obj) {
		var a = document.getElementById("scdd.chbm").value;
		//alert(a);
		$.post("scjhgl/chbmjy", {
			"a" : a
		}, function(data) {
			/*  //alert(data);
			 console.log(data); */
			if (data == "success") {

				layer.alert("请在pdm中添加此产品工艺！");
				document.getElementById("scdd.chbm").value = "";
			}/* else if(data =="success11"){
						layer.alert("该产品已添加完毕！");
						document.getElementById("scdd.chbm").value = "";
						}  */
			else {
				document.getElementById("scdd.chmc").value = data;
			}
		});
	}

	function clickEdita(obj) {
		var id = obj.attr("useid");
		var jhpcs = $("#jhpcs" + id).val();
		//alert(jhpcs);
		if (jhpcs > 0) {
			$.post("scjhgl/jhpcsjya", {
				"jhpcs" : jhpcs,
				"id" : id
			}, function(data) {//data表示接收后台传递的参数,
				//alert(data);
				if (data == "success") {
					layer.alert("计划排产数大于订单数量，请重新输入");
					//showPage1(1);
					idlist = '';
				} else {

				}
				;

			});
		} else {
			layer.alert("请输入合理数据！！！");

		}

	}

	//司机看见了没 就改这一点就行了！！！！！！

	/* function PageFoot1(data) {
			if(data.totalPage==1){
			}
			else{
			
			
			$("#dynamic-table_paginate1").hide();
				laypage({
					cont : $('#pagefoot1'), //容器。值支持id名、原生dom对象，jquery对象,
					pages : data.totalPage, //总页数
					skip : true, //是否开启跳页
					skin : '#2283C5',//保持ace中间的样式
					first : 1,
					last : data.totalPage, //总页数，将尾页显示为总页数
					curr : data.pageNumber,//当前页
					groups : 5, //连续显示分页数
					jump : function(obj, first) {
						if (!first) { //一定要加此判断，否则初始时会无限刷新
							showPage1(obj.curr);
						}
					}
				});
			}	
	};
	 */
	function PageFoot1(data) {
		//alert(data.totalPage);
		if (data.totalPage != 1) {
			$("#laypage_1").addClass("hide");
			$("#get_pagination1").removeClass("hide");
			laypage({
				cont : $('#get_pagination1'), //容器。值支持id名、原生dom对象，jquery对象,
				pages : data.totalPage, //总页数
				skip : true, //是否开启跳页
				skin : '#2283C5',//保持ace中间的样式;
				first : 1,
				last : data.totalPage, //总页数，将尾页显示为总页数
				curr : data.pageNumber,//当前页
				groups : 5, //连续显示分页数
				jump : function(obj, first) {
					if (!first) { //一定要加此判断，否则初始时会无限刷新
						//alert(obj.curr);
						//oldpageChange(obj.curr);
						showPage1(obj.curr);
					}
				}
			});
		} else {
			$("#get_pagination1").addClass("hide");
			$("#laypage_1").removeClass("hide");
		}

	}

	//判断显数据量
	$(".selectclass").change(function() {

		$.post("scjhgl/select_records", {
			"select" : $(".selectclass").val()
		}, function(data) {

			showPage1(1);
		});
	});

	$("option").click(function() {

	});

	//});
</script>


<script type="text/javascript">
	//已排产订单

	// 导出 

	function writeExcel2() {

		var aa = '已排产';
		// alert(aa);
		$.post("date/writeExcel", {
			"aa" : aa
		}, function(data) {
			if (data == "ss") {

				alert("导出成功，在C盘根目录请注意查收！");
				window.location = "#scjhgl/index";
			} else {
				alert("导出失败");
				window.location = "#scjhgl/index";
			}

		});
	}

	//查询时清除其他输入框的数据
	function clears1() {
		document.getElementById("ww2").value = "";
		document.getElementById("ww3").value = "";
	}

	function clears2() {
		document.getElementById("ww1").value = "";
		document.getElementById("ww3").value = "";
	}

	function clears3() {
		document.getElementById("ww1").value = "";
		document.getElementById("ww2").value = "";
	}

	//已排产查询
	$("#selectfromsb2").click(function() {
		var sel = document.getElementById("ww1");
		var sel1 = document.getElementById("ww2");
		var sel2 = document.getElementById("ww3");

		$.post("scjhgl/sele2", {
			"scddh" : sel.value,
			"khjc" : sel1.value,
			"chbm" : sel2.value
		}, function(data) {
			showPage2(1);
		});
		return false;
	});

	/* function bb() {//当刷新页面时重新执行查询方法
		$.post("scjhgl/sele2",$("#selefrom2").serialize(),function(data){
					showPage2(1);
		});
		}
	  bb();//调用查询方法 */

	function YPC(data) { //已排产
		var dataStr = "";
		$
				.each(
						data,
						function(i, a) {
							$
									.each(
											a.paginate.list,
											function(i, v) { //v. _ddscljxx表数据   a.paginate.list -->v
												dataStr += '<tr>';

												dataStr += '<td><input name="checkboxs2"  id="checkboxs2" class="ace" type="checkbox" value="'+v.id+'"/> <span class="lbl"></span></td>';

												if (v.scddh == null
														|| v.scddh == 'null'
														|| v.scddh == '') {
													dataStr += '<td style="width:90px;height:30px " >'
															+ '' + '</td>';//生产订单号
												} else {
													dataStr += '<td style="width:90px;height:30px " >'
															+ v.scddh + '</td>';//生产订单号
												}

												dataStr += '<td style="width:90px;height:30px ">';
												$
														.each(
																a.scdd,
																function(i, m) {
																	if (m.scddh == v.scddh)
																		if (m.fhrq == null
																				|| m.fhrq == 'null'
																				|| m.fhrq == '') {
																			dataStr += ''; //发货日期
																		} else {
																			dataStr += m.fhrq; //发货日期
																		}
																});
												dataStr += '</td>';

												dataStr += '<td style="width:90px;height:30px ">';
												$
														.each(
																a.scdd,
																function(i, m) {
																	if (m.scddh == v.scddh)
																		if (m.khjc == null
																				|| m.khjc == 'null'
																				|| m.khjc == '') {
																			dataStr += ''; //客户简称
																		} else {
																			dataStr += m.khjc
																					.substring(
																							0,
																							4); //客户简称
																		}
																});
												dataStr += '</td>';

												dataStr += '<td>';
												$
														.each(
																a.scdd,
																function(i, m) {
																	if (m.scddh == v.scddh)
																		if (m.chbm == null
																				|| m.chbm == 'null'
																				|| m.chbm == '') {
																			dataStr += ''; //存货编码
																		} else {
																			dataStr += m.chbm; //存货编码
																		}
																});
												dataStr += '</td>';

												/* $.each(a.scdd, function(i, m) {
													if(m.scddh==v.scddh){
													var a=m.chbm;
													alert(a);
													}}); */

												dataStr += '<td style="width:90px;height:30px ">';
												$
														.each(
																a.scdd,
																function(i, m) {
																	if (m.scddh == v.scddh)
																		if (m.chmc == null
																				|| m.chmc == 'null'
																				|| m.chmc == '') {
																			dataStr += ''; //存货名称
																		} else {
																			dataStr += m.chmc
																					.substring(
																							0,
																							4); //存货名称
																		}
																});
												dataStr += '</td>';

												dataStr += '<td style="width:90px;height:30px ">';
												$
														.each(
																a.scdd,
																function(i, m) {
																	if (m.scddh == v.scddh)
																		if (m.ggxh == null
																				|| m.ggxh == 'null'
																				|| m.ggxh == '') {
																			dataStr += ''; //规格型号
																		} else {
																			dataStr += m.ggxh
																					.substring(
																							0,
																							4); //规格型号
																		}
																});
												dataStr += '</td>';

												dataStr += '<td>';
												$
														.each(
																a.scdd,
																function(i, m) {
																	if (m.scddh == v.scddh)
																		if (m.dw == null
																				|| m.dw == 'null'
																				|| m.dw == '') {
																			dataStr += '';//单位
																		} else {
																			dataStr += m.dw; //单位
																		}
																});
												dataStr += '</td>';

												dataStr += '<td>';
												$
														.each(
																a.scdd,
																function(i, m) {
																	if (m.scddh == v.scddh)
																		if (m.ddsl == null
																				|| m.ddsl == 'null'
																				|| m.ddsl == '') {
																			dataStr += ''; //订单数量
																		} else {
																			dataStr += m.ddsl; //订单数量
																		}
																});
												dataStr += '</td>';

												if (v.pcbzxh == null
														|| v.pcbzxh == 'null'
														|| v.pcbzxh == '') {
													dataStr += '<td>' + ''
															+ '</td>';//生产序号
												} else {
													dataStr += '<td>'
															+ v.pcbzxh
															+ '</td>';//生产序号
												}

												dataStr += '<td style="width:60px;height:30px " class="pcbzbh'+v.id+'">';
												$
														.each(
																a.scbz,
																function(i, m) {
																	if (m.dept_id == v.pcbzbh)
																		if (m.dept_name == null
																				|| m.dept_name == 'null'
																				|| m.dept_name == '') {
																			dataStr += ''; //生产班组名称(部门表)
																		} else {
																			dataStr += m.dept_name; //生产班组名称(部门表)
																		}
																});
												dataStr += '</td>';

												if (v.bzljpcs == null
														|| v.bzljpcs == 'null'
														|| v.bzljpcs == '') {
													dataStr += '<td>' + ''
															+ '</td>';//班组累计排产数
												} else {
													dataStr += '<td>'
															+ v.bzljpcs
															+ '</td>';//班组累计排产数
												}

												var wcsl = 0;
												$.ajax({
													type : "post",
													url : "scjhgl/find",
													async : false,
													data : {
														"scddh" : v.scddh,
														"pcbzbh" : v.pcbzbh,
														"id" : v.id
													},
													success : function(data) {
														wcsl = data;//获取后台传递的累计完工数
													}
												});

												dataStr += '<td class="bzljwgs">'
														+ wcsl + '</td>';//班组累计完工数

												/* if(v.dpcs==null||v.dpcs=='null'||v.dpcs==''){
												dataStr += '<td  >' +''
														+ '</td>';//待排产数
												}else{ */
												dataStr += '<td  >' + v.dpcs
														+ '</td>';//待排产数
												//}
												//计划排产班组
												dataStr += '<td><input type="hidden" value="'+v.id+'"  class="bzh'+v.id+'"/><select name="selevalue"  scbzid="'+v.id+'" class="scbzbbb form-control" style="width:80px"  id="selevalue"><option value="79" >表贴组</option><option value="80" >仪表组</option><option value="81" >电器盒组</option><option value="82" >电子组</option><option value="83" >电瓶仓组</option><option value="84"  >开关组</option> </select></td>';
												//dataStr += '<td  class="jhpcs'+v.id+'" ><input type="hidden" value="'+v.id+'" /><input name="jhpcs" type="text" useeid="'+v.id+'" class="caaabb11" style="width:60px;height:30px "  id="qaz"  value="0"  /></td>';
												dataStr += '<td  class=" jhpcs'+v.id+'"><input type="hidden" id="hqid" value="'+v.id+'" /><input name="jhpcs" type="text" useid="'+v.id+'" class="caaabb11 form-control editButton dddd'+i+'" style="width:60px;height:30px " id="jhpcs'+v.id+'"  value="0"  /></td>';

												dataStr += '</tr>';
											});
						});
		$("#table_2").html(dataStr);

		$(".caaabb11").blur(function() {
			var aaa = $("#selevalue").val();
			//alert(aaa);
			var a = $(".caaabb11")[0].value;
			var hqid = $("#hqid").val();

			var bzh = this.parentNode.previousSibling.lastChild.value;//DOM对象的取值
			//var said = this.parentNode.parentNode.id;
			//console.log(said);
			clickEdit121($(this), bzh);

		});

	}

	$("#caaabb11").blur(function() {
		alert("aaaaa");
	});

	/* function trList2(data) {
		var dataStr = "";
		$.each(data, function(i, v) {
			dataStr += YPC(v);
		});
		// 把拼接好的表格内容填充到指定位置
		$("#table_2").html(dataStr);
		
		
		$(".cbbb").blur(function() {
	    clickEdi($(this));
	    return false;
	    });
	}  */

	function clickEdit121(obj, bzh) {

		var id = obj.attr("useid");
		var jhpcs = $("#jhpcs" + id).val();
		if (jhpcs >= 1) {

			$.post("scjhgl/jhpcsjy", {
				"jhpcs" : jhpcs,
				"bzh" : bzh,
				"id" : id
			}, function(data) {//data表示接收后台传递的参数,
				//alert(data);
				if (data == "success") {
					layer.alert("计划排产数大于待排产数，请重新输入！");
					//showPage2(1);
					idlist = '';
				} else if (data == "success11") {
					layer.alert("计划排产数大于累计完工数，请重新输入");
					//showPage2(1); 														
				} else if (data == "success112") {
					layer.alert("请输入合理的排产班组！");
					//showPage2(1); 														
				} else if (data == "success113") {
					layer.alert("请在下一班组中排产！");
					//showPage2(1); 														
				} else if (data == "success114") {
					layer.alert("请输入合理的排产数！！");
					//showPage2(1); 														
				} else {

				}
				;

			});
		} else {
			layer.alert("请输入合理的计划排产数！");
		}

	}

	/* 
	function PageFoot2(data) {
		var n = "";
		var backword = "上一页";
		var forword = "下一页";
		var x = data.PageNumber; //当前页
		var back; //前一页
		var next; //后一页
		if (x = 1) { //对上一页的判断		
			back = 1;
		} else {
			back = x - 1;
		}
		if (x < data.totalPage) { //对下一页判断
			next = x + 1;
		} else {
			next = data.totalPage;
		}

		n += "<li onclick=\"showPage2(" + back + ")\"><a>" + backword
				+ "</a></li>&nbsp;&nbsp;";
		for (var a = 1; a <= data.totalPage; a++) {
			if (a == data.PageNumber) {
				n += "<li class=\"active\" onclick=\"showPage2(" + a
						+ ")\"><a>" + a + "</a></li>&nbsp;&nbsp;";
			} else {
				n += "<li onclick=\"showPage2(" + a + ")\"><a>" + a
						+ "</a></li>&nbsp;&nbsp;";
			}
			;
		}
		n += "<li onclick=\"showPage2(" + next + ")\"><a>" + forword
				+ "</a></li>&nbsp;&nbsp;";

		$("#pagefoot2").html(n); //把循环好的页码给替换掉
	}; */
	function PageFoot2(data) {
		//alert(data.totalPage);
		if (data.totalPage != 1) {
			$("#laypage_2").addClass("hide");
			$("#get_pagination2").removeClass("hide");
			laypage({
				cont : $('#get_pagination2'), //容器。值支持id名、原生dom对象，jquery对象,
				pages : data.totalPage, //总页数
				skip : true, //是否开启跳页
				skin : '#2283C5',//保持ace中间的样式;
				first : 1,
				last : data.totalPage, //总页数，将尾页显示为总页数
				curr : data.pageNumber,//当前页
				groups : 5, //连续显示分页数
				jump : function(obj, first) {
					if (!first) { //一定要加此判断，否则初始时会无限刷新
						//alert(obj.curr);
						//oldpageChange(obj.curr);
						showPage2(obj.curr);
					}
				}
			});
		} else {
			$("#get_pagination2").addClass("hide");
			$("#laypage_2").removeClass("hide");
		}

	}
	//获取分页数据列表并显示
	function showPage2(curr) {
		$.get("scjhgl/Tbody_list2", {
			"pageNumber" : curr,
			"size1" : $(".selectclass1").val()
		}, function(data) {
			YPC(data);
			PageFoot2(data[0].paginate); //调用的PageFoot方法，循环输出页码连接    
		});
	}
	showPage2(1); //刚进入页面为第一页，列出第一页数据和页脚

	$(".selectclass1").change(function() {

		$.post("scjhgl/select_records", {
			"select" : $(".selectclass1").val()
		}, function(data) {

			showPage2(1);
		});
	});

	$("option").click(function() {

	});
</script>


<script type="text/javascript">
	//入库及闭单

	//查询时输入框以外的输入框清空
	function clears4() {
		document.getElementById("abcd1").value = "";
		document.getElementById("abcd2").value = "";
		document.getElementById("abcd3").value = "";
	}

	//入库及闭单查询
	$("#selectfromsb3").click(function() {
		$.post("scjhgl/sele3", $("#selefrom3").serialize(), function(data) {
			showPage3(1);
			/* PageFoot1(data[0].paginate); */
		});
		return false;
	});

	/* function bb() {//当刷新页面时重新执行查询方法
		$.post("scjhgl/sele3",$("#selefrom2").serialize(),function(data){
					showPage3(1);
		});
		}
	  cc();//调用查询方法 */

	function YBD(data) { //已闭单
		var dataStr = "";
		$
				.each(
						data,
						function(i, a) {
							$
									.each(
											a.paginate.list,
											function(i, v) { //v. _ rscjh表数据   a.paginate.list -->v
												dataStr += '<tr>';
												dataStr += '<td><input name="checkboxs3"  id="checkboxs3" class="ace" type="checkbox" value="'+v.id+'"/> <span class="lbl"></span></td>';

												if (v.scddh == null
														|| v.scddh == 'null'
														|| v.scddh == '') {
													dataStr += '<td>' + ''
															+ '</td>';//生产订单号
												} else {
													dataStr += '<td>' + v.scddh
															+ '</td>';//生产订单号
												}

												if (v.fhrq == null
														|| v.fhrq == 'null'
														|| v.fhrq == '') {
													dataStr += '<td>' + ''
															+ '</td>';//发货日期
												} else {
													dataStr += '<td>' + v.fhrq
															+ '</td>';//发货日期
												}

												if (v.khjc == null
														|| v.khjc == 'null'
														|| v.khjc == '') {
													dataStr += '<td>' + ''
															+ '</td>';//客户简称
												} else {
													dataStr += '<td>'
															+ v.khjc.substring(
																	0, 4)
															+ '</td>';//客户简称
												}

												if (v.chbm == null
														|| v.chbm == 'null'
														|| v.chbm == '') {
													dataStr += '<td>' + ''
															+ '</td>';//存货编码
												} else {
													dataStr += '<td>' + v.chbm
															+ '</td>';//存货编码
												}

												if (v.chmc == null
														|| v.chmc == 'null'
														|| v.chmc == '') {
													dataStr += '<td>' + ''
															+ '</td>';//存货名称
												} else {
													dataStr += '<td>' + v.chmc
															+ '</td>';//存货名称
												}

												if (v.ggxh == null
														|| v.ggxh == 'null'
														|| v.ggxh == '') {
													dataStr += '<td>' + ''
															+ '</td>';//规格型号
												} else {
													dataStr += '<td>' + v.ggxh
															+ '</td>';//规格型号
												}

												if (v.dw == null
														|| v.dw == 'null'
														|| v.dw == '') {
													//var ddww='';
													dataStr += '<td>' + ''
															+ '</td>';//单位
												} else {
													dataStr += '<td>' + v.dw
															+ '</td>';//单位
												}

												if (v.ddsl == null
														|| v.ddsl == 'null'
														|| v.ddsl == '') {
													dataStr += '<td>' + ''
															+ '</td>';//订单数量
												} else {
													dataStr += '<td>' + v.ddsl
															+ '</td>';//订单数量
												}

												/* if(v.yrks==null||v.yrks=='null'||v.yrks==''){
												dataStr += '<td  class=" yrks'+v.id+'" id="yrksq" ><input type="hidden" value="'+v.id+'"   /><input name="yrks" type="text" useid="'+v.id+'" class="yrks11 form-control editButton dddd'+i+'" style="width:60px;height:30px " id="yrks'+v.id+'"  value="'+''+'"  /></td>';								
												}else{ */
												dataStr += '<td  class=" yrks'+v.id+'" id="yrksq" ><input type="hidden" value="'+v.id+'"   /><input name="yrks" type="text" useid="'+v.id+'" class="yrks11 form-control editButton dddd'+i+'" style="width:60px;height:30px " id="yrks'+v.id+'"  value="'+v.yrks+'"  /></td>';
												//}
												dataStr += '</tr>';
											});
						});
		//return dataStr;
		$("#table_3").html(dataStr);

		$(".yrks11").blur(function() {

			clickEdit12($(this));
			//window.location = "#scjhgl/index" ;
			return false;

		});

	}
	//获取分页数据列表并显示
	function showPage3(curr) {
		$.get("scjhgl/Tbody_list3", {
			"pageNumber" : curr,
			"size2" : $(".selectclass2").val()
		}, function(data) {
			//trList3(data.list); //调用上面trList()方法，填充表格数据
			//PageFoot3(data); //调用下面的writePageFoot方法，循环输出页码连接
			YBD(data);
			PageFoot3(data[0].paginate); //调用的PageFoot方法，循环输出页码连接      
		});
	}
	showPage3(1); //~暂不理解 ,应该是刚进入页面为第一页，列出第一页数据和页脚

	function clickEdit12(obj) {
		var id = obj.attr("useid");
		var yrks = $("#yrks" + id).val();
		if (!isNaN(yrks)) {

			$.post("scjhgl/luru12", {
				"yrks" : yrks,
				"id" : id
			}, function(data) {//data表示接收后台传递的参数,"wwgs":z,

				if (data == "success") {
					showPage3(1);
				} else {
					document.getElementById("yrksq").value = "0";
					layer.alert("请输入合理的数据！");
				}
			});
		} else {
			layer.msg("请输入正确的数据格式！！！");
		}
	}

	function PageFoot3(data) {
		//alert(data.totalPage);
		if (data.totalPage != 1) {
			$("#laypage_3").addClass("hide");
			$("#get_pagination3").removeClass("hide");
			laypage({
				cont : $('#get_pagination3'), //容器。值支持id名、原生dom对象，jquery对象,
				pages : data.totalPage, //总页数
				skip : true, //是否开启跳页
				skin : '#2283C5',//保持ace中间的样式;
				first : 1,
				last : data.totalPage, //总页数，将尾页显示为总页数
				curr : data.pageNumber,//当前页
				groups : 5, //连续显示分页数
				jump : function(obj, first) {
					if (!first) { //一定要加此判断，否则初始时会无限刷新
						//alert(obj.curr);
						//oldpageChange(obj.curr);
						showPage3(obj.curr);
					}
				}
			});
		} else {
			$("#get_pagination3").addClass("hide");
			$("#laypage_3").removeClass("hide");
		}

	}

	$(".selectclass2").change(function() {

		$.post("scjhgl/select_records", {
			"select" : $(".selectclass2").val()
		}, function(data) {

			showPage3(1);
		});
	});

	$("option").click(function() {

	});
</script>



<script type="text/javascript">
	/*  var jhpc=document.getElementsByTagName('table')[0].rows.length;
			 		console.log(jhpc); */

	/*未排产的进行排产  */
	$("#pc1")
			.click(
					function(event) {
						/*  var xuan = $("input[type=checkbox]:checked");
						var zhilist= new Array(); 
						for(var i=0;i<xuan.length;i++){
						
						  // var zhi2='';
						   //var zhi3='';
							zhi = xuan.eq(i).parent("td").siblings("td:last").children("input:last").val();	
							//zhi2 = xuan.eq(1).parent("td").siblings("td:last").children("input:last").val();
							zhilist.push(zhi);
							alert(zhilist);
							//zhi2 = xuan.eq(1).parent("td").siblings("td:last").children("input:last").val();
							//zhi3 = xuan.eq(2).parent("td").siblings("td:last").children("input:last").val();
							//alert(zhi);//查看排产数量
						} */
						//alert(zhi);
						//var zhilist=[zhi1,zhi2];
						//var a=$(".caaabb")[0].value;
						//alert(a);
						var xuan = $("input[type=checkbox]:checked");

						var zhilist = '';
						for (var i = 0; i < xuan.length; i++) {
							zhi = xuan.eq(i).parent("td").siblings("td:last")
									.children("input:last").val();
							zhilist += zhi + ',';

						}
						if (zhilist.length > 0) {
							zhilist = zhilist.substring(0, zhilist.length - 1);
						}
						;
						//  alert(zhilist);	

						var ls = $("input[type=checkbox]:checked").size(); //选中的个数
						if (ls != "") {

							function GetDateStr(AddDayCount) {

								var dd = new Date();

								dd.setDate(dd.getDate() + AddDayCount);//获取AddDayCount天后的日期

								var y = dd.getFullYear();

								var m = dd.getMonth() + 1;//获取当前月份的日期

								var d = dd.getDate();

								return y + "-" + m + "-" + d;

							}

							var now = new Date(); //获取当前时间----------------
							var hour = now.getHours();
							if (hour >= 12) {

								clock = GetDateStr(2);
							
							} else {
								clock = GetDateStr(1);

							}

							layer.confirm('<p><center>排产到&nbsp<input name="rscjhbh" type="text"  id="rscjhbh" style="width:110px;height:30px "  onClick="WdatePicker()"  value="'
													+ clock+ '" /><select name="selevalue1"  style="width:155px;height:30px " class="form-control"  id="selevalue111" ><option value="79" >表贴组</option><option value="80" >仪表组</option><option value="81" >电器盒组</option><option value="82" >电子组</option><option value="82" >电瓶仓组</option><option value="84"  >开关组</option></select></center></p>',
											{
												btn : [ '确认', '取消' ]
											//按钮
											},
											function() {
												var rscjhbh = $("#rscjhbh")
														.val();
												var selevalue111 = $(
														"#selevalue111").val();
												//alert(selevalue111);
												var idlist = '';

												$(
														"input[type='checkbox'][name='checkboxs1']")
														.filter(':checked')
														.each(
																function() {
																	idlist = idlist
																			+ $(
																					this)
																					.val()
																			+ ",";
																	//var zhi = xuan.eq(i).parent("td").siblings("td:last").children("input:last").val();

																});
												if (idlist.length > 0) {
													idlist = idlist.substring(
															0,
															idlist.length - 1);

													$
															.post(
																	"scjhgl/PC1",
																	{
																		"idlist" : idlist,
																		"rscjhbh" : rscjhbh,
																		"selevalue111" : selevalue111,
																		"zhilist" : zhilist
																	},
																	function(
																			data) {
																		if (data == "success") {
																			showPage1(1);
																			layer
																					.closeAll('dialog');//关闭所有弹窗
																			idlist = '';
																			zhilist = '';
																		} else if (data == "asdfg") {
																			document
																					.getElementById("qazaa").value = "0";
																			layer
																					.alert("请输入合理的数据！");
																		} else {
																			document
																					.getElementById("qaz1").value = "0";
																			layer
																					.alert("请输入合理的数据！");
																		}
																	});

												}
												layer.colse();
											}, function() {
											});
						} else {
							layer.alert("请选择要排产的数据！");
						}
						return false;
					});

	/* 删除数据	 */
	$("#pc11").click(
			function(event) {
				var ls = $("input[type=checkbox]:checked").size(); //选中的个数
				if (ls != "") {

					layer.confirm('确定删除？', {
						btn : [ '确认', '取消' ]
					//按钮
					}, function() {
						var idlist = '';
						$("input[type='checkbox'][name='checkboxs1']").filter(
								':checked').each(function() {
							idlist = idlist + $(this).val() + ",";
						});
						if (idlist.length > 0) {
							idlist = idlist.substring(0, idlist.length - 1);
							$.post("scjhgl/d", {
								"idlist" : idlist
							}, function(data) {
								if (data == "success") {
									showPage1(1);
									layer.closeAll('dialog');//关闭所有弹窗
									idlist = '';
								}
							});
						}
						layer.colse();
					}, function() {

					});
				} else {
					layer.alert("请选择要删除的数据！");
				}
				return false;
			});
	/*已排产的进行排产  */
	$("#pc2")
			.click(
					function(event) {

						var xuan = $("input[type=checkbox]:checked");
						var zhilist = '';
						var zhilist1 = '';
						for (var i = 0; i < xuan.length; i++) {

							var zhi = xuan.eq(i).parent("td").siblings(
									"td:last").children("input:last").val();
							var zhi1 = xuan.eq(i).parent("td").siblings("td")
									.eq(13).children("select:first").val();
							zhilist += zhi + ',';
							zhilist1 += zhi1 + ',';
						}

						if (zhilist.length > 0) {
							zhilist = zhilist.substring(0, zhilist.length - 1);
						}
						;
						if (zhilist1.length > 0) {
							zhilist1 = zhilist1.substring(0,
									zhilist1.length - 1);
						}
						;
						// alert(zhilist);
						//  alert(zhilist1);

						var ls = $("input[type=checkbox]:checked").size(); //选中的个数
						if (ls != "") {

							function GetDateStr(AddDayCount) {

								var dd = new Date();

								dd.setDate(dd.getDate() + AddDayCount);//获取AddDayCount天后的日期

								var y = dd.getFullYear();

								var m = dd.getMonth() + 1;//获取当前月份的日期

								var d = dd.getDate();

								return y + "-" + m + "-" + d;

							}

							var now = new Date(); //获取当前时间----------------
							var hour = now.getHours();
							if (hour >= 12) {

								clock = GetDateStr(2);
								

							} else {
								clock = GetDateStr(1);

							}

							layer
									.confirm(
											'<td>排产到<input name="rscjhbh" type="text"  id="rscjhbh1" style="width:160px;height:30px "   onClick="WdatePicker()"  value="'
													+ clock + '" />日生产计划</td>',
											{
												btn : [ '确认', '取消' ]
											//按钮
											},
											function() {
												var rscjhbh1 = $("#rscjhbh1")
														.val();
												var idlist = '';

												$(
														"input[type='checkbox'][name='checkboxs2']")
														.filter(':checked')
														.each(
																function() {
																	idlist = idlist
																			+ $(
																					this)
																					.val()
																			+ ",";
																	var zhi = xuan
																			.eq(
																					i)
																			.parent(
																					"td")
																			.siblings(
																					"td:last")
																			.children(
																					"input:last")
																			.val();
																	var zhi1 = xuan
																			.eq(
																					i)
																			.parent(
																					"td")
																			.siblings(
																					"td")
																			.eq(
																					13)
																			.children(
																					"select:first")
																			.val();
																});
												if (idlist.length > 0) {
													idlist = idlist.substring(
															0,
															idlist.length - 1);
													$
															.post(
																	"scjhgl/PC2",
																	{
																		"idlist" : idlist,
																		"rscjhbh1" : rscjhbh1,
																		"zhilist" : zhilist,
																		"zhilist1" : zhilist1
																	},
																	function(
																			data) {

																		if (data == "success") {
																			//location.reload();
																			showPage2(1);
																			layer
																					.closeAll('dialog');//关闭所有弹窗
																			idlist = '';
																		} else if (data == "aaaaa") {
																			//document.getElementById("qaz").value="0";
																			layer
																					.alert("该产品已经排产完毕！");
																			//showPage2(1);
																			//return false;

																		} else if (data == "aaaaa11") {

																			//document.getElementById("qaz").value="0";
																			layer
																					.alert("计划排产数已经大于待排产数，请重新输入");
																			//showPage2(1);
																			return false;

																			//document.getElementById("qaz").value="00";
																		} else if (data == "aaaaa112") {

																			//document.getElementById("qaz").value="0";
																			//alert(data[1]);

																			layer
																					.alert("计划排产数已经大于累计完工数，请重新输入");
																			//showPage2(1);
																			//return false;
																			//document.getElementById("qaz").value="00";
																		} else if (data == "aaaaa113") {

																			//document.getElementById("qaz").value="0";
																			layer
																					.alert("请选择正确的排产班组！");
																			showPage2(1);
																			//return false;
																			//document.getElementById("qaz").value="00";
																		} else if (data == "aaaaa114") {
																			layer
																					.alert("请输入合理的数据！");
																		} else {

																			//document.getElementByName("qaz").value="0";
																			layer
																					.alert("请输入合理的数据！");
																			showPage2(1);

																		}
																		//alert(data);

																	});
												}

												layer.colse();
											}, function() {

											});
						} else {
							layer.alert("请选择要排产的数据！");
						}
						return false;
					});

	//////////////////////////////闭单	

	function BD() {

		var xuan = $("input[type=checkbox]:checked");
		var zhilist = '';

		for (var i = 0; i < xuan.length; i++) {

			var zhi = xuan.eq(i).parent("td").siblings("td:last").children(
					"input:last").val();
			zhilist += zhi + ',';

		}

		if (zhilist.length > 0) {
			zhilist = zhilist.substring(0, zhilist.length - 1);
		}
		;
		//alert(zhilist);

		var ls = $("input[type=checkbox]:checked").size(); //选中的个数
		if (ls != "") {

			layer.confirm('确定闭单？', {
				btn : [ '确认', '取消' ]
			//按钮
			}, function() {
				var idlist = '';
				$("input[type='checkbox'][name='checkboxs3']").filter(
						':checked').each(function() {
					idlist = idlist + $(this).val() + ",";
				});
				if (idlist.length > 0) {
					idlist = idlist.substring(0, idlist.length - 1);
					$.post("scjhgl/BD", {
						"idlist" : idlist,
						"zhilist" : zhilist
					}, function(data) {
						if (data == "success") {
							showPage3(1);
							layer.closeAll('dialog');//关闭所有弹窗
							//location.reload();
							idlist = '';
						} else {
							layer.alert("请输入合理的数据！");
						}
					});
				}
				layer.colse();
			}, function() {

			});
		} else {
			layer.alert("请选择要闭单的数据！");
		}
	}

	
	$('table th input:checkbox').on(
			'click',
			function() { /*复选框js_全选  */
				var that = this;
				$(this).closest('table').find(
						'tr > td:first-child input:checkbox').each(function() {
					this.checked = that.checked;
					$(this).closest('tr').toggleClass('selected');
				});

			});

	function addForm() {
		document.getElementById("pform").reset();
		$('#add').removeClass("hide");
		userModel = layer.open({
			type : 1,
			shade : [ 0.5 ],
			title : "<div  ><h4 class='smaller blue'>销售订单录入</div>", //不显示标题
			area : [ '32%', '350px' ], //显示空间
			content : $('#add'), //捕获的元素
			btn : [ '保存', '返回' ],
			yes : function(index, layero) { //或者使用btn1
				var a = document.getElementById("scdd.xsddh").value;
				var b = document.getElementById("scdd.khjc").value;
				var c = document.getElementById("scdd.chbm").value;

				var d = document.getElementById("scdd.chmc").value;
				var e = document.getElementById("scdd.fhrq").value;
				var f = document.getElementById("scdd.ddsl").value;

				if ((a && b && c && d && e && f) == "") {
					layer.msg("有空值哦！");
					return !true;
				} else {

					$.post("scjhgl/c", $("#pform").serialize(), function(data) {
						//layer.close(index);

						showPage1(1);
						document.getElementById("pform").reset();
					});
					/* $.post("add", $("#pform").serialize(), function(data) {
					
					// alert();  
					layer.close(index);	
					$('#add').addClass("hide");
					document.getElementById("pform").submit();
					
					}); */
				}
			},
			cancel : function(index) {
				layer.close(index);
				$('#add').addClass("hide"); //取消继续隐藏
			},
		});
	};
</script>

<script>
	/*修改销售订单1 */
	function updateForm1(id, scddh, khjc, chbm, chmc, ggxh, fhrq, dw, ddsl,
			xpcs, bz) {
		document.getElementById("updateFormA").reset();
		$("#id").val(id);
		$("#scddh").val(scddh);
		$("#khjc").val(khjc);
		$("#chbm").val(chbm);
		$("#chmc").val(chmc);
		$("#ggxh").val(ggxh);
		$("#fhrq").val(fhrq);
		$("#dw").val(dw);
		$("#ddsl").val(ddsl);
		$("#xpcs").val(xpcs);
		$("#bz").val(bz);
		$('#update1').removeClass("hide");
		userModel = layer.open({
			type : 1,
			shade : [ 0.5 ],
			title : '修改销售订单信息', //不显示标题
			area : [ '60%', '420px' ], //显示空间
			content : $('#update1'), //捕获的元素
			btn : [ '确定', '取消' ],
			yes : function(index, layero) { //或者使用btn1
				$.post("update1", $("#updateFormA").serialize(),
						function(data) {

							layer.close(index);
							$('#update1').addClass("hide");
							document.getElementById("updateFormA").submit();
						});
			},
			cancel : function(index) {
				layer.close(index);
				$('#update1').addClass("hide"); //取消继续隐藏
			},
		});
	};
</script>
<script>
	/*修改销售订单2 */
	function updateForm2(id, scddh, khjc, chbm, chmc, ggxh, fhrq, dw, xpcs,
			ypcs, dpcs, wwgs, bz) {
		document.getElementById("updateFormB").reset();
		$("#id2").val(id);
		$("#scddh2").val(scddh);
		$("#khjc2").val(khjc);
		$("#chbm2").val(chbm);
		$("#chmc2").val(chmc);
		$("#ggxh2").val(ggxh);
		$("#fhrq2").val(fhrq);
		$("#dw2").val(dw);
		$("#xpcs2").val(xpcs);
		$("#ypcs2").val(ypcs);
		$("#dpcs2").val(dpcs);
		$("#wwgs2").val(wwgs);
		$("#bz2").val(bz);
		$('#update2').removeClass("hide");
		userModel = layer.open({
			type : 1,
			shade : [ 0.5 ],
			title : '修改销售订单信息', //不显示标题
			area : [ '60%', '500px' ], //显示空间
			content : $('#update2'), //捕获的元素
			btn : [ '确定', '取消' ],
			yes : function(index, layero) { //或者使用btn1
				$.post("update2", $("#updateFormB").serialize(),
						function(data) {

							layer.close(index);
							$('#update2').addClass("hide");
							document.getElementById("updateFormB").submit();
						});
			},
			cancel : function(index) {
				layer.close(index);
				$('#update2').addClass("hide"); //取消继续隐藏
			},
		});
	};
</script>


<script type="text/javascript">
	jQuery(function($) {
		$.widget("ui.dialog", $.extend({}, $.ui.dialog.prototype, {
			_title : function(title) {
				var $title = this.options.title || '&nbsp;';
				if (("title_html" in this.options)
						&& this.options.title_html == true)
					title.html($title);
				else
					title.text($title);
			}
		}));

		//initiate dataTables plugin						初始化表格插件
		/* var oTable1 = $('#dynamic-table')
		//.wrap("<div class='dataTables_borderWrap' />")   //if you are applying horizontal scrolling (sScrollX)
		.dataTable({
			bAutoWidth : false,
			"aoColumns" : [ null, null, null, null, null, null, {
				"bSortable" : false
			} ],
			"aaSorting" : [],

		}); */
		//oTable1.fnAdjustColumnSizing();
		//TableTools settings
		TableTools.classes.container = "btn-group btn-overlap";
		TableTools.classes.print = {
			"body" : "DTTT_Print",
			"info" : "tableTools-alert gritter-item-wrapper gritter-info gritter-center white",
			"message" : "tableTools-print-navbar"
		};

		//initiate TableTools extension
		var tableTools_obj = new $.fn.dataTable.TableTools(
				oTable1,
				{
					"sSwfPath" : "plugins/ace/assets/js/dataTables/extensions/TableTools/swf/copy_csv_xls_pdf.swf", //in Ace demo plugins/ace/assets will be replaced by correct assets path

					"sRowSelector" : "td:not(:last-child)",
					"sRowSelect" : "multi",
					"fnRowSelected" : function(row) {
						//check checkbox when row is selected
						try {
							$(row).find('input[type=checkbox]').get(0).checked = true
						} catch (e) {
						}
					},
					"fnRowDeselected" : function(row) {
						//uncheck checkbox
						try {
							$(row).find('input[type=checkbox]').get(0).checked = false
						} catch (e) {
						}
					},

					"sSelectedClass" : "success",
					"aButtons" : [
							{
								"sExtends" : "copy",
								"sToolTip" : "复制到剪贴板",
								"sButtonClass" : "btn btn-white btn-primary btn-bold",
								"sButtonText" : "<i class='fa fa-copy bigger-110 pink'></i>",
								"fnComplete" : function() {
									this.fnInfo(
											'<h3 class="no-margin-top smaller">表格已复制</h3>\
							<p>已复制 '
													+ (oTable1.fnSettings()
															.fnRecordsTotal())
													+ ' 行数据到剪贴板.</p>', 1500);
								}
							},

							{
								"sExtends" : "csv",
								"sToolTip" : "导出成 CSV",
								"sButtonClass" : "btn btn-white btn-primary  btn-bold",
								"sButtonText" : "<i class='fa fa-file-excel-o bigger-110 green'></i>"
							},

							{
								"sExtends" : "pdf",
								"sToolTip" : "导出成 PDF",
								"sButtonClass" : "btn btn-white btn-primary  btn-bold",
								"sButtonText" : "<i class='fa fa-file-pdf-o bigger-110 red'></i>"
							},

							{
								"sExtends" : "print",
								"sToolTip" : "打印页面",
								"sButtonClass" : "btn btn-white btn-primary  btn-bold",
								"sButtonText" : "<i class='fa fa-print bigger-110 grey'></i>",

								"sMessage" : "<div class='navbar navbar-default'><div class='navbar-header pull-left'><a class='navbar-brand' href='#'><small>可选导航栏 &amp; 文本</small></a></div></div>",

								"sInfo" : "<h3 class='no-margin-top'>打印页面</h3>\
							  <p>请用您的浏览器打印功能打印这个表格 \
							  <br />请打印完成关闭此页面</p>",
							} ]
				});

		//we put a container before our table and append TableTools element to it
		$(tableTools_obj.fnContainer()).appendTo($('.tableTools-container'));

		//also add tooltips to table tools buttons
		//addding tooltips directly to "A" buttons results in buttons disappearing (weired! don't know why!)
		//so we add tooltips to the "DIV" child after it becomes inserted
		//flash objects inside table tools buttons are inserted with some delay (100ms) (for some reason)
		setTimeout(function() {
			$(tableTools_obj.fnContainer()).find('a.DTTT_button').each(
					function() {
						var div = $(this).find('> div');
						if (div.length > 0)
							div.tooltip({
								container : 'body'
							});
						else
							$(this).tooltip({
								container : 'body'
							});
					});
		}, 200);

		//ColVis extension
		var colvis = new $.fn.dataTable.ColVis(oTable1, {
			"buttonText" : "<i class='fa fa-search'></i>",
			"aiExclude" : [ 0, 6 ],
			"bShowAll" : true,
			//"bRestore": true,
			"sAlign" : "right",
			"fnLabel" : function(i, title, th) {
				return $(th).text();//remove icons, etc
			}

		});

		//style it
		$(colvis.button()).addClass('btn-group').find('button').addClass(
				'btn btn-white btn-info btn-bold')

		//and append it to our table tools btn-group, also add tooltip
		$(colvis.button()).prependTo('.tableTools-container .btn-group').attr(
				'title', '显示/隐藏 数据列').tooltip({
			container : 'body'
		});

		//and make the list, buttons and checkboxed Ace-like
		$(colvis.dom.collection)
				.addClass(
						'dropdown-menu dropdown-light dropdown-caret dropdown-caret-right')
				.find('li').wrapInner('<a href="javascript:void(0)" />') //'A' tag is required for better styling
				.find('input[type=checkbox]').addClass('ace').next().addClass(
						'lbl padding-8');

		//table checkboxes
		$('th input[type=checkbox], td input[type=checkbox]').prop('checked',
				false);

		//select/deselect all rows according to table header checkbox
		$('#dynamic-table > thead > tr > th input[type=checkbox]').eq(0).on(
				'click',
				function() {
					var th_checked = this.checked;//checkbox inside "TH" table header

					$(this).closest('table').find('tbody > tr').each(
							function() {
								var row = this;
								if (th_checked)
									tableTools_obj.fnSelect(row);
								else
									tableTools_obj.fnDeselect(row);
							});
				});

		//select/deselect a row when the checkbox is checked/unchecked
		$('#dynamic-table').on('click', 'td input[type=checkbox]', function() {
			var row = $(this).closest('tr').get(0);
			if (!this.checked)
				tableTools_obj.fnSelect(row);
			else
				tableTools_obj.fnDeselect($(this).closest('tr').get(0));
		});

		$(document).on('click', '#dynamic-table .dropdown-toggle', function(e) {
			e.stopImmediatePropagation();
			e.stopPropagation();
			e.preventDefault();
		});

		//And for the first simple table, which doesn't have TableTools or dataTables
		//select/deselect all rows according to table header checkbox
		var active_class = 'active';
		$('#simple-table > thead > tr > th input[type=checkbox]').eq(0).on(
				'click',
				function() {
					var th_checked = this.checked;//checkbox inside "TH" table header

					$(this).closest('table').find('tbody > tr').each(
							function() {
								var row = this;
								if (th_checked)
									$(row).addClass(active_class).find(
											'input[type=checkbox]').eq(0).prop(
											'checked', true);
								else
									$(row).removeClass(active_class).find(
											'input[type=checkbox]').eq(0).prop(
											'checked', false);
							});
				});

		//select/deselect a row when the checkbox is checked/unchecked
		$('#simple-table').on('click', 'td input[type=checkbox]', function() {
			var $row = $(this).closest('tr');
			if (this.checked)
				$row.addClass(active_class);
			else
				$row.removeClass(active_class);
		});

		/********************************/
		//add tooltip for small view action buttons in dropdown menu
		$('[data-rel="tooltip"]').tooltip({
			placement : tooltip_placement
		});

		//tooltip placement on right or left
		function tooltip_placement(context, source) {
			var $source = $(source);
			var $parent = $source.closest('table');
			var off1 = $parent.offset();
			var w1 = $parent.width();

			var off2 = $source.offset();
			//var w2 = $source.width();

			if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2))
				return 'right';
			return 'left';
		}

	});
</script>